<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>开关</title>
    <link rel="stylesheet" href="../../../demo/icon/iconfont.css">
    <style>
        @font-face {
            font-family: 'iconfont';
            src: url('../../../demo/icon/iconfont.ttf?t=1638151981418') format('truetype');
        }
        .iconfont {
            font-family: "iconfont" !important;
            font-size: 16px;
            font-style: normal;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
        }
        .switch {
            width: 400px;
            height: 200px;
            background-color: grey;
            border-radius: 100px;
            padding: 10px;
            /* 改变盒子被撑开的方式 */
            /* content-box: 正常的盒子模型 padding(内边距) & border(边框) 都会把盒子撑大 */
            /* border-box: 往内撑开的盒子模型 padding(内边距) & border(边框) 都不会影响盒子的大小 但是会压缩内容的空间 */
            box-sizing: border-box;
            position: relative;
            font-size: 50px;
            color: white;
        }

        .switch .circle {
            position: absolute;
            width: 180px;
            height: 180px;
            border-radius: 50%;
            background-color: white;
            transition: transform 1s ease;
        }
        .switch:hover {
            /* 鼠标 小手 */
            cursor: pointer;
        }
        .switch:hover .circle {
            transform: translateX(200px);
        }
        /* 使用伪元素画v和x */
        .switch::before {
            content: "\e6cf";
            display: block;
            width: 180px;
            height: 180px;
            line-height: 180px;
            text-align: center;
            right: 10px;
            transition: right 1s ease;
            position: absolute;
            font-family: "iconfont" !important;
            font-style: normal;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
        }
        /* 鼠标悬停 把x换成v 并且移动位置 */
        .switch:hover::before {
            content: "\e71c";
            right: 200px;
        }
    </style>
</head>
<body>
    <div class="switch">
        <div class="circle"></div>
    </div>
</body>
</html>